package com.shazhu.web.controller.nongjt;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.shazhu.common.annotation.Log;
import com.shazhu.common.core.controller.BaseController;
import com.shazhu.common.core.domain.AjaxResult;
import com.shazhu.common.enums.BusinessType;
import com.shazhu.nongjt.domain.NjtPrinterAuth;
import com.shazhu.nongjt.service.INjtPrinterAuthService;
import com.shazhu.common.utils.poi.ExcelUtil;
import com.shazhu.common.core.page.TableDataInfo;

/**
 * 打印机认证记录Controller
 * 
 * @author shazhu
 * @date 2025-09-29
 */
@RestController
@RequestMapping("/nongjt/auth")
public class NjtPrinterAuthController extends BaseController
{
    @Autowired
    private INjtPrinterAuthService njtPrinterAuthService;

    /**
     * 查询打印机认证记录列表
     */
    @PreAuthorize("@ss.hasPermi('nongjt:auth:list')")
    @GetMapping("/list")
    public TableDataInfo list(NjtPrinterAuth njtPrinterAuth)
    {
        startPage();
        List<NjtPrinterAuth> list = njtPrinterAuthService.selectNjtPrinterAuthList(njtPrinterAuth);
        return getDataTable(list);
    }

    /**
     * 导出打印机认证记录列表
     */
    @PreAuthorize("@ss.hasPermi('nongjt:auth:export')")
    @Log(title = "打印机认证记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NjtPrinterAuth njtPrinterAuth)
    {
        List<NjtPrinterAuth> list = njtPrinterAuthService.selectNjtPrinterAuthList(njtPrinterAuth);
        ExcelUtil<NjtPrinterAuth> util = new ExcelUtil<NjtPrinterAuth>(NjtPrinterAuth.class);
        util.exportExcel(response, list, "打印机认证记录数据");
    }

    /**
     * 获取打印机认证记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('nongjt:auth:query')")
    @GetMapping(value = "/{authId}")
    public AjaxResult getInfo(@PathVariable("authId") Long authId)
    {
        return success(njtPrinterAuthService.selectNjtPrinterAuthByAuthId(authId));
    }

    /**
     * 新增打印机认证记录
     */
    @PreAuthorize("@ss.hasPermi('nongjt:auth:add')")
    @Log(title = "打印机认证记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Valid @RequestBody NjtPrinterAuth njtPrinterAuth)
    {
        return toAjax(njtPrinterAuthService.insertNjtPrinterAuth(njtPrinterAuth));
    }

    /**
     * 修改打印机认证记录
     */
    @PreAuthorize("@ss.hasPermi('nongjt:auth:edit')")
    @Log(title = "打印机认证记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Valid @RequestBody NjtPrinterAuth njtPrinterAuth)
    {
        return toAjax(njtPrinterAuthService.updateNjtPrinterAuth(njtPrinterAuth));
    }

    /**
     * 删除打印机认证记录
     */
    @PreAuthorize("@ss.hasPermi('nongjt:auth:remove')")
    @Log(title = "打印机认证记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{authIds}")
    public AjaxResult remove(@PathVariable Long[] authIds)
    {
        return toAjax(njtPrinterAuthService.deleteNjtPrinterAuthByAuthIds(authIds));
    }
}